import * as actionTypes from '../actions/ActionTypes';

import { handleActions } from 'redux-actions';

//公司查看简历
const defData = {
    xzResume: {},
    isloading: true//是否读取ing1
}
export const SelResumeInfoComReducer = handleActions({
    [actionTypes.SEL_RESUMEINFOCOM]: {
        next(state, action) {
            return { ret: true, data: action.payload };
        },
        throw(state, action) {
            return { ret: false, statusText: "报错", data: defData };
        }
    }
}, { ret: true, statusText: '默认', data: defData });

//公司-职位管理-查看投递的简历
const defData9 = {
    resumeList: [],
    sendtime: {},
    posSend:{},
    isloading: true//是否读取ing1
};
export const SelResumeByPosReducer = handleActions({
    [actionTypes.SEL_RESUMEBYPOS]: {
        next(state, action) {
            if (action.payload.page !== 1) {
                action.payload.resumeList = state.data.resumeList.concat(action.payload.resumeList);
            }
            return {ret: true, isloading: false, data: action.payload};
        },
        throw() {
            return {ret: false, isloading: false, statusText: "报错", data: defData9};
        }
    }
}, {ret: true, isloading:true,statusText: '默认', data: defData9});

//公司查询投递的简历
const defData1 = {
    List: [],
    isloading: true//是否读取ing1
}
export const SelStateMobReducer = handleActions({
    [actionTypes.SEL_STATE_MOB]: {
        next(state, action) {
            if (action.payload.page != 1) {
                action.payload.List = state.data.List.concat(action.payload.List);
            }
            return { ret: true, isloading: false, data: action.payload };
        },
        throw(state, action) {
            return { ret: false, isloading: false, data: defData1 };
        }
    }
}, { ret: true, isloading:true, statusText: '默认', data: defData1 });

//公司查询投递的简历
const defData2 = {
    resumeList: [],
    isloading: true//是否读取ing1
}
export const SelResumeByConditionsReducer = handleActions({
    [actionTypes.SEL_RESUME_CONDITONS]: {
        next(state, action) {
            if (action.payload.page != 1) {
                action.payload.resumeList = state.data.resumeList.concat(action.payload.resumeList);
            }
            return { ret: true, isloading: false, data: action.payload };
        },
        throw(state, action) {
            return { ret: false, isloading: false, data: defData2 };
        }
    }
}, { ret: true, isloading:true, statusText: '默认', data: defData2 });